/*
 * Created on 15 avr. 2005 by Tudor.Ionescu@supelec.fr
 */
package clustering.framework;

/**
 * @author Tudor.Ionescu@supelec.fr
 * @
 */
public class QNode{
	public int id=-1;
    public int label=-1;
    // neighbors list
    public QNode [] adj = new QNode[3];
    public int db_i1, db_i2;
    public QNode(int label,QNode n0,QNode n1,QNode n2,int id){
        adj[0] = n0;
        adj[1] = n1;
        adj[2] = n2;
        this.label = label;
        this.id = id;
    }
    public QNode(int label,QNode n0,QNode n1,QNode n2){
        adj[0] = n0;
        adj[1] = n1;
        adj[2] = n2;
        this.label = label;
    }
    // returns the index of an adjacent node in the
    // adjacency list of the current node
    public int getAdjIndex(QNode adjnode){
        for(int i=0;i<adj.length;i++){
            if(adj[i]==adjnode)return i;
        }
        return -1;
    }
    // returns the index of an adjacent node in the
    // adjacency list, given the two other adjacent nodes
    public int getThirdAdjIndex(QNode n1, QNode n2){
        db_i1 = -2;
    	db_i2 = -2;
        int i1 = getAdjIndex(n1);
    	int i2 = getAdjIndex(n2);
    	db_i1 = i1;
    	db_i2 = i2;
    	for(int i=0;i<adj.length;i++){
    	    if(i != i1 && i != i2)return i;
    	}
    	return -1;
    }
}
